package com.sgcc.sx.pmos.mobileapp.utils;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.lxj.xpopup.core.CenterPopupView;
import com.sgcc.pmos.nativesdk.R;
import com.sgcc.sx.pmos.mobileapp.adapter.DataDifferentItemAdapter;
import com.sgcc.sx.pmos.mobileapp.bean.DataDifferentItemBean;

import java.util.List;

/**
 * @author ChaoAJ
 * @describe 关联企业信息数据异常提示
 * @time 2022/8/29 14:10
 */
public class DataDifferentDialog extends CenterPopupView {

    private RecyclerView rvDataList;
    private List<DataDifferentItemBean> list;
    private OnConfirmClickListener onConfirmClickListener;

    private String text;

    public DataDifferentDialog(Context context, String text, List<DataDifferentItemBean> list,
                               OnConfirmClickListener onConfirmClickListener) {
        super(context);
        this.list = list;
        this.text = text;
        this.onConfirmClickListener = onConfirmClickListener;

    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.dialog_data_different_layout;
    }

    @Override
    protected void onCreate() {
        super.onCreate();

        rvDataList = (RecyclerView) findViewById(R.id.rvDataList);
        TextView tvHideText = findViewById(R.id.tvHideText);
        tvHideText.setText(text);
        rvDataList.setLayoutManager(new LinearLayoutManager(getContext()));
        DataDifferentItemAdapter dataDifferentItemAdapter = new DataDifferentItemAdapter(list);
        rvDataList.setAdapter(dataDifferentItemAdapter);
        findViewById(R.id.tvCancel).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });
        findViewById(R.id.tvConfirm).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
                onConfirmClickListener.onConfirm();
            }
        });


    }

    @Override
    protected void onShow() {
        super.onShow();
    }

    @Override
    protected void onDismiss() {
        super.onDismiss();
    }


    @Override
    protected int getMaxHeight() {
        return 1200;

    }

    public interface OnConfirmClickListener {


        void onConfirm();

    }

}